package com.jetinno.simple.utils

import android.os.Environment
import java.io.File

/**
 * Description : 专门管理文件路径的类
 * Author : mhwang
 * Date : 2017/11/23
 * Version : V1.0
 */
object FilePath {
    const val ROOT_NAME = "Jetinno"

    @JvmField
    val EXTERNAL_STORAGE_FILE: File = Environment.getExternalStorageDirectory()

    // 文件根路径
    @JvmField
    val ROOT_PATH: String = EXTERNAL_STORAGE_FILE.toString() + File.separator + ROOT_NAME
    const val AaDatas_NAME = "AaDatas"

    @JvmField
    val AaDatas_PATH: String = EXTERNAL_STORAGE_FILE.toString() + File.separator + AaDatas_NAME

    @JvmField
    val IMG_SUFFIXS = arrayOf(".gif", ".png", ".jpg")

    @JvmField
    val IMG_SUFFIXS2 = arrayOf(".png", ".jpg", ".jpeg")

    const val product_config_name = "product_config.json"
    const val recipe_config_name = "recipe_config.json"
    const val canister_config_name = "canister_config.json"
    const val translate_config_name = "translate_config.json"
    const val donate_config_name = "donate_config.json"
    const val presetadv_config_name = "presetadv_config.json"
    const val presetpower_config_name = "presetpower_config.json"
    const val global_config_name = "global_config.json"
    const val mdb_config_name = "mdb_config.json"
    const val menu_config_name = "menu_config.json"
    const val pay_config_name = "pay_config.json"
    const val MilkInterval_name = "MilkInterval.json"
    const val fault_config_name = "fault_config.json"
    const val waste_warning_name = "waste_warning_config.json"
    const val ProductImage_name = "ProductImage"
    const val GroupImage_name = "GroupImage"
    const val ProductImageBig_name = "ProductImageBig"
    const val ProductImageFinish_name = "ProductImageFinish"
    const val CustomPictures_name = "CustomPictures"
    const val Config_name = "Config"
    const val Sound_name = "Sound"
    const val Libs_name = "Libs"

    /**
     * 导出消息的分割线
     */
    const val RECIPE_SUFFIX = ".recipe"
    const val JSON_SUFFIX = ".json"
    const val PRODUCT_SUFFIX = ".product"
    const val DEX_SUFFIX = ".dex"
    const val PRODUCT_CLASS_SUFFIX = ".productclass"
    const val PRODUCT_GROUP_SUFFIX = ".productgroup"
    const val IOCONFIG = ".ioconfig"
    const val IOPROGRAM = ".ioprogram"

    object Suffix {
        const val PNG = ".png"
        const val JPG = ".jpg"
        const val JPEG = ".jpeg"
        const val GIF = ".gif"
        const val MP4 = ".mp4"
        const val MKV = ".mkv"
        const val AVI = ".avi"
        const val RMVB = ".rmvb"
    }

    @JvmStatic
    fun isImage(fileName: String): Boolean {
        return fileName.endsWith(Suffix.PNG) || fileName.endsWith(Suffix.JPG) || fileName.endsWith(
            Suffix.JPEG
        )
    }

    @JvmStatic
    fun isGif(fileName: String): Boolean {
        return fileName.endsWith(Suffix.GIF)
    }

    object Jetinno {
        // ini配置文件
        // 配置文件存储路径
        @JvmField
        val Config: String = ROOT_PATH + File.separator + "Config"

        // 日志文件夹
        @JvmField
        val CustomPictures: String = ROOT_PATH + File.separator + CustomPictures_name

        // 售卖模块等web数据
        @JvmField
        val Html: String = ROOT_PATH + File.separator + "Html"

        // 订单日志等
        @JvmField
        val Log: String = ROOT_PATH + File.separator + "Log"

        // 饮品浓度信息
        @JvmField
        val NutritionInfo: String = ROOT_PATH + File.separator + "NutritionInfo"

        // 饮品图片
        @JvmField
        val ProductImage: String = ROOT_PATH + File.separator + ProductImage_name

        // 分组图片
        @JvmField
        val GroupImage: String = ROOT_PATH + File.separator + GroupImage_name

        // 饮品大图
        @JvmField
        val ProductImageBig: String = ROOT_PATH + File.separator + ProductImageBig_name

        // 饮品完成图
        @JvmField
        val ProductImageFinish: String = ROOT_PATH + File.separator + ProductImageFinish_name

        // 屏保图
        @JvmField
        val ScreenProtect: String = ROOT_PATH + File.separator + "ScreenProtect"

        // 下载资源
        @JvmField
        val Download: String = ROOT_PATH + File.separator + "Download"

        // 支付图片
        @JvmField
        val RadioButtonImage: String = ROOT_PATH + File.separator + "RadioButtonImage"

        // 资源图片
        @JvmField
        val Drawable: String = ROOT_PATH + File.separator + "Drawable"

        // 订单
        @JvmField
        val Order: String = ROOT_PATH + File.separator + "Order"

        // 数据
        @JvmField
        val Data: String = ROOT_PATH + File.separator + "Data"

        // 微信刷脸支付商户信息参数配置文件
        @JvmField
        val bussiness_params: String = ROOT_PATH + File.separator + "bussiness_params.wxfp"

        @JvmField
        val JetinnoSystemApk: String = ROOT_PATH + File.separator + "jetinnosystem.apk"

        // 文件和字段释义
        @JvmField
        val document: String = ROOT_PATH + File.separator + "document.json"

        @JvmField
        val Io: String = ROOT_PATH + File.separator + "Io"

        @JvmField
        val Sound: String = ROOT_PATH + File.separator + Sound_name
        val Libs: String = ROOT_PATH + File.separator + Libs_name
    }

    object Config {
        // 配置文件global_config.ini所在路径
        @JvmField
        val global_config: String = Jetinno.Config + File.separator + global_config_name

        // 配置文件mdb_config.json所在路径
        @JvmField
        val mdb_config: String = Jetinno.Config + File.separator + mdb_config_name

        // 配置文件menu_config.json所在路径
        @JvmField
        val menu_config: String = Jetinno.Config + File.separator + menu_config_name

        // 配置文件pay_config.ini所在路径
        @JvmField
        val pay_config: String = Jetinno.Config + File.separator + pay_config_name

        // 配置文件canister_config.ini所在路径
        @JvmField
        val canister_config: String = Jetinno.Config + File.separator + canister_config_name

        // 故障文件
        @JvmField
        val fault_config: String = Jetinno.Config + File.separator + fault_config_name

        // 翻译文件
        @JvmField
        val translate_config: String = Jetinno.Config + File.separator + translate_config_name

        @JvmField
        val donate_config: String = Jetinno.Config + File.separator + donate_config_name

        // 预设广告
        @JvmField
        val presetadv_config: String = Jetinno.Config + File.separator + presetadv_config_name

        // 预设休眠
        @JvmField
        val presetpower_config: String = Jetinno.Config + File.separator + presetpower_config_name
    }

    object Data {
        // APP数据MilkInterval.xml所在路径
        @JvmField
        val MilkInterval: String = Jetinno.Data + File.separator + MilkInterval_name

        // 配置文件pay_config.json所在路径
        @JvmField
        val pay_config: String = Jetinno.Data + File.separator + pay_config_name

        // 配置文件canister_config.json所在路径
        @JvmField
        val canister_config: String = Jetinno.Data + File.separator + canister_config_name

        // 配置文件recipe_config.json所在路径
        @JvmField
        val recipe_config: String = Jetinno.Data + File.separator + recipe_config_name

        // 配置文件product_config.json所在路径
        @JvmField
        val product_config: String = Jetinno.Data + File.separator + product_config_name
    }

    object Custom {
        @JvmField
        val ic_public_sign: String =
            Jetinno.CustomPictures + File.separator + "ic_public_sign"  // 客服二维码图片

        @JvmField
        val ic_loading: String =
            Jetinno.CustomPictures + File.separator + "ic_loading" // 首页启动图片,引导页面背景图片

        @JvmField
        val ic_home_background: String =
            Jetinno.CustomPictures + File.separator + "ic_home_background"  // 首页背景图片

        @JvmField
        val ic_error: String = Jetinno.CustomPictures + File.separator + "ic_error"  // 维护图片，补货页面

        @JvmField
        val gif_lack_recipe: String =
            Jetinno.CustomPictures + File.separator + "gif_lack_recipe" // 维护图片

        @JvmField
        val ic_making_product: String =
            Jetinno.CustomPictures + File.separator + "ic_making_product"  // 咖啡制作中

        @JvmField
        val ic_product_finish: String =
            Jetinno.CustomPictures + File.separator + "ic_product_finish" // 咖啡制作结束

        @JvmField
        val ic_logo: String = Jetinno.CustomPictures + File.separator + "ic_logo.png" // menuic_logo

        @JvmField
        val menuic_qr_middle: String =
            Jetinno.CustomPictures + File.separator + "menuic_qr_middle.png" // menuic_qr_middle
    }

    object Html {
        @JvmField
        val Menu: String = Jetinno.Html + File.separator + "Menu"
    }

    object Download {
        @JvmField
        val Apk: String = Jetinno.Download + File.separator + "Apk"

        @JvmField
        val JetinnoFolder: String = Jetinno.Download + File.separator + "Jetinno"
    }

    object Log {
        @JvmField
        val Order: String = Jetinno.Log + File.separator + "Order" + File.separator + "order"
    }

    object Drawable

    object AaDatas {
        @JvmField
        val Logcat: String = AaDatas_PATH + File.separator + "Logcat"
    }

    object Libs {
        val libmdb: String = Jetinno.Libs + File.separator + "libmdbLib.so"
    }

    @JvmStatic
    fun getDrawablePath(drawableName: String?): String {
        return Jetinno.CustomPictures + File.separator + drawableName + Suffix.PNG
    }

    @JvmStatic
    fun getGifPath(drawableName: String?): String {
        return Jetinno.CustomPictures + File.separator + drawableName + Suffix.GIF
    }

    @JvmStatic
    fun getGroupImagePath(picName: String?): String {
        return Jetinno.GroupImage + File.separator + picName
    }
}